<?php
// jimport('infinity.variables');
abstract class Variables {
    public static function set($key, $value) {
    	$value = serialize($value);
    	$db = JFactory::getDbo();
    	$db->setQuery('DELETE FROM #__variables WHERE `key`='.$db->Quote($key));
    	$db->query();
    	$db->setQuery('INSERT INTO #__variables (`key`, `value`)VALUES('.$db->Quote($key).','.$db->Quote($value).')');
    	$db->query();
    	return true;
    }

    public static function get($key, $default_value) {
    	$db = JFactory::getDbo();
    	$db->setQuery('SELECT `value` FROM #__variables WHERE `key`='.$db->Quote($key));
    	$result = $db->loadResult();
    	if(!$result)
    		$result = $default_value;
    	else
    		$result = unserialize($result);
    	return $result;
    }
}
